package com.colin.userservice.controller;

import com.colin.bean.User;
import com.colin.response.R;
import com.colin.userservice.service.UserService;
import com.sun.org.apache.xpath.internal.operations.Bool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/{username}")
    public R<Boolean> checkUsernaemIsExist(@PathVariable String username) {
        System.out.println(userService.checkUsernameIsExist(username));
        return userService.checkUsernameIsExist(username);
    }

    @PostMapping
    public R<Boolean> doRegister(@RequestBody User user) {
        return userService.doRegister(user);
    }

    @PostMapping("/auth")
    public R<User> login(@RequestBody User user) {
        return userService.doLogin(user);
    }
}
